<?php
// +----------------------------------------------------------------------
// | snake
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 http://baiyf.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: NickBai <1902822973@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\model\NodeModel;
use think\Db;
class Index extends Base
{
    public function index()
    {
        // 获取权限菜单
        $node = new NodeModel();
        $this->assign([
            'menu' => $node->getMenu(session('rule'))
        ]);

        return $this->fetch('/index');
    }

    /**
     * 后台默认首页
     * @return mixed
     */
    public function indexPage()
    {
        //    	$today = strtotime("-1 day");
//        $today = strtotime(date("Y-m-d"));
//        $count['handle_order'] = Db::name('order')->where("order_status=0 and (pay_status=1 or pay_code='cod')")->count();//待处理订单
//        $count['new_record'] = Db::name('record')->where("add_time>=$today")->count();//今天新增订单
//        $count['record'] =  Db::name('record')->count();//提交发票总数
//        $count['article'] =  Db::name('article')->where("1=1")->count();//文章总数
//        $count['users'] = Db::name('iuser')->where("1=1")->count();//会员总数
//        $count['today_login'] = Db::name('users')->where("last_login>=$today")->count();//今日访问
//        $count['new_users'] = Db::name('iuser')->where("addtime>=".$today)->count();//今日新增会员数
//        $count['comment'] = Db::name('comment')->where("is_show=0")->count();//最新评论
//        $this->assign('count',$count);
//        return $this->fetch();
        return view('index/welcome',['count'=>'','sys_info'=>$this->get_sys_info()]);
    }


    public function get_sys_info(){
        $sys_info['os']             = PHP_OS;
        $sys_info['zlib']           = function_exists('gzclose') ? 'YES' : 'NO';//zlib
        $sys_info['safe_mode']      = (boolean) ini_get('safe_mode') ? 'YES' : 'NO';//safe_mode = Off
        $sys_info['timezone']       = function_exists("date_default_timezone_get") ? date_default_timezone_get() : "no_timezone";
        $sys_info['curl']			= function_exists('curl_init') ? 'YES' : 'NO';
        $sys_info['web_server']     = $_SERVER['SERVER_SOFTWARE'];
        $sys_info['phpv']           = phpversion();
        $sys_info['ip'] 			= GetHostByName($_SERVER['SERVER_NAME']);
        $sys_info['fileupload']     = @ini_get('file_uploads') ? ini_get('upload_max_filesize') :'unknown';
        $sys_info['max_ex_time'] 	= @ini_get("max_execution_time").'s'; //脚本最大执行时间
        $sys_info['set_time_limit'] = function_exists("set_time_limit") ? true : false;
        $sys_info['domain'] 		= $_SERVER['HTTP_HOST'];
        $sys_info['memory_limit']   = ini_get('memory_limit');
//        $sys_info['version']   	    = file_get_contents(APP_PATH.'admin/conf/version.php');
        $mysqlinfo = Db::query("SELECT VERSION() as version");
        $sys_info['mysql_version']  = $mysqlinfo[0]['version'];
        if(function_exists("gd_info")){
            $gd = gd_info();
            $sys_info['gdinfo'] 	= $gd['GD Version'];
        }else {
            $sys_info['gdinfo'] 	= "未知";
        }
        return $sys_info;
    }
}
